package com.yc.star.web;


import com.yc.star.entity.User;
import com.yc.star.service.IUService;
import com.yc.star.vo.RedisUtil;
import com.yc.star.vo.Result;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@RequestMapping("match")
public class MatchDo {


    @Resource
    IUService iuService;

    @Resource
    RedisUtil redisUtil;

    /**
     * 获取最匹配的用户
     *
//     * @param num  long num,
     * @param request
     * @return
     */
    @GetMapping("matchuser")
    public Result matchUsers( HttpServletRequest request) {
//        if (num <= 0 || num > 20) {
//            System.out.println("多");
//        }
        String token = request.getHeader("Token");
        User user = (User) redisUtil.get(token);
        System.out.println(user);
        List<User> list = iuService.matchUsers(5,user);
        return new Result(1 ,"success",list);
    }
}
